/*
 *   Copyright (c) 2010-2022, SIUFUNG
 */
package net.siufung.market.base.tenant.controller.assembler;

import com.google.common.collect.Lists;
import java.util.List;
import java.util.Objects;
import net.siufung.core.utils.CopyUtil;
import org.springframework.util.CollectionUtils;
import net.siufung.market.base.tenant.mapper.entity.TenantQuota;
import net.siufung.market.base.tenant.controller.model.vo.TenantQuotaVo;

/**
 *
 * 系统租户配额表 持久层展示层组装器
 *
 * @author 陈建峰
 * @since 2022-07-06 14:45:08
 */
public class TenantQuotaAssembler {

    /**
     * TenantQuota 转换成 TenantQuotaVo
     * @param tenantQuota 数据库实体
     * @return TenantQuotaVo 视图
     */
    public static TenantQuotaVo from(TenantQuota tenantQuota){
        if(!Objects.isNull(tenantQuota)){
            TenantQuotaVo tenantQuotaVo = new TenantQuotaVo();
            CopyUtil.copyProperties(tenantQuota, tenantQuotaVo);
            return tenantQuotaVo;
        }
        return null;
    }

    /**
     * TenantQuotaList 转换成 TenantQuotaVoList
     * @param tenantQuotaList 数据库实体集合
     * @return List<TenantQuotaVo> 视图集合
     */
    public static List<TenantQuotaVo> fromList(List<TenantQuota> tenantQuotaList){
        List<TenantQuotaVo> tenantQuotaVoList = Lists.newArrayList();
        if(!CollectionUtils.isEmpty(tenantQuotaList)){
            TenantQuotaVo tenantQuotaVo;
            for (TenantQuota tenantQuota: tenantQuotaList) {
                tenantQuotaVo = new TenantQuotaVo();
                CopyUtil.copyProperties(tenantQuota, tenantQuotaVo);
                tenantQuotaVoList.add(tenantQuotaVo);
            }
        }
        return tenantQuotaVoList;
    }
}

